package insight.google.game.era.bo.card;

import insight.google.game.era.core.Util;
import insight.google.game.era.data.Card;
import insight.google.game.era.data.policys.Policy;
import insight.google.game.era.bo.GameUser;
import insight.google.game.era.bo.policy.AbstractPolicy;
import insight.google.game.era.bo.policy.PolicyCenter;
import insight.google.game.era.bo.policy.character.CaoCaoPolicy;
import insight.google.game.era.bo.policy.character.CharacterPolicy;
import insight.google.game.era.bo.policy.character.GuoJiaPolicy;
import insight.google.game.era.bo.policy.character.LiuBeiPolicy;
import insight.google.game.era.bo.policy.character.SunQuanPolicy;
import insight.google.game.era.bo.policy.character.ZhangFeiPolicy;
import insight.google.game.era.bo.policy.character.ZhouYuPolicy;

import java.util.ArrayList;
import java.util.List;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

import org.directwebremoting.annotations.DataTransferObject;
import org.directwebremoting.annotations.RemoteProperty;
@DataTransferObject
public class CharacterCard extends Card {
	
	/**
	 * 
	 */
	public static int TYPE_KING = 1;
	public static int TYPE_GENERAL = 0;

	protected int characterType;
	
//	@RemoteProperty
	protected int blood = 4;
	
	@RemoteProperty
	protected String policyDescription = "";
	
	protected int playCardCount = 2;
	
	protected int keepCardCount = 4;
	
	@Persistent(mappedBy="characterCard")
	private GameUser user;
	
	public CharacterCard(String id, String name){
		this.id = id;
		this.name = name;
	}
	
	
	public GameUser getUser() {
		return user;
	}






	public void setUser(GameUser user) {
		this.user = user;
	}
	public static List<CharacterCard> getCharacterCard(int noOfUsers){
		List<CharacterCard>	cardList = new ArrayList<CharacterCard>();
		
		//set cao cao character card.
		CharacterCard card = new CharacterCard("caocao", "Cao Cao");
		card.setCharacterType(CharacterCard.TYPE_KING);
		List<Integer> policyList = new ArrayList<Integer>();
		//set cao cao policy --JianXiong
		policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_CAOCAO_JIANXIOING);
		//set the second policy --HuJia
//		policy = new CaoCaoPolicy("huJia", "HuJia");
//		policy.setType(CharacterPolicy.TYPE_BE_HURTED);
//		policy.setIsFixed(true);
//		policyList.add(policy);
		card.setPolicyList(policyList);
		card.setPolicyDescription("Get the card that hurt to lost life auto.");
		cardList.add(card);
		
		//set liu bei character card.
		card = new CharacterCard("liubei", "Liu Bei");
		card.setCharacterType(CharacterCard.TYPE_GENERAL);
		policyList = new ArrayList<Integer>();
		policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_LIUBEI_RENDE);
	//		policy = new CaoCaoPolicy("jiJiang", "JiJiang");
	//		policy.setType(CharacterPolicy.TYPE_BE_HURTED);
	//		policy.setIsFixed(true);
	//		policyList.add(policy);
		card.setPolicyList(policyList);
		card.setPolicyDescription("Send cards to one selected user, each send two card can plus one life.");
		cardList.add(card);

		//set sun quan character card.
		card = new CharacterCard("sunquan", "Sun Quan");
		card.setCharacterType(CharacterCard.TYPE_GENERAL);
		policyList = new ArrayList<Integer>();
		policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_SUNQUAN_ZHIHENG);
		card.setPolicyList(policyList);
		card.setPolicyDescription("Select cards to change new cards.");
		cardList.add(card);

		//set zhang fei character card.
		card = new CharacterCard("zhangfei", "Zhang Fei");
		card.setCharacterType(CharacterCard.TYPE_GENERAL);
		policyList = new ArrayList<Integer>();
		policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_ZHANGFEI_PAOXIAO);
		card.setPolicyList(policyList);
		card.setPolicyDescription("No limit to do attack card.");
		cardList.add(card);
		
		//set zhou yu character card.
		card = new CharacterCard("zhouyu", "Zhou Yu");
		card.setCharacterType(CharacterCard.TYPE_GENERAL);
		policyList = new ArrayList<Integer>();
		policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_ZHOUYU_YINZI);
		card.setPolicyList(policyList);
		card.setPolicyDescription("Get three cards on his turn.");
		cardList.add(card);
		
		//set Guo Jia character card.
		card = new CharacterCard("guojia", "Guo Jia");
		card.setCharacterType(CharacterCard.TYPE_GENERAL);
		policyList = new ArrayList<Integer>();
		policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_GUOJIA_YIJI);
		card.setPolicyList(policyList);
		card.setPolicyDescription("Get two cards auto, when be hurt to lost life.");
		cardList.add(card);
		
		//set Zhao Yun character card.
		card = new CharacterCard("zhaoyun", "Zhao Yun");
		card.setCharacterType(CharacterCard.TYPE_GENERAL);
		policyList = new ArrayList<Integer>();
		policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_ZHAOYUN_LONGDAN);
		card.setPolicyList(policyList);
		card.setPolicyDescription("output attack card as defend card, or output defend card as attack card.");
		cardList.add(card);
		
		//set Huang Gai character card.
		card = new CharacterCard("huanggai", "Huang Gai");
		card.setCharacterType(CharacterCard.TYPE_GENERAL);
		policyList = new ArrayList<Integer>();
		policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_HUANGGAI_KUROU);
		card.setPolicyList(policyList);
		card.setPolicyDescription("Cut one point life initiative to get two cards");
		cardList.add(card);
		
		Util.shuffleCards(cardList,1);
		List<CharacterCard> returnCards = new ArrayList<CharacterCard>();
		for (int i = 0; i < noOfUsers; i++) {
			returnCards.add(cardList.get(i));
		}
//		Util.shuffleCards(returnCards);
		return returnCards;
	}

	public int getBlood() {
		return blood;
	}

	public void setBlood(int blood) {
		this.blood = blood;
	}

	public int getPlayCardCount() {
		return playCardCount;
	}

	public void setPlayCardCount(int playCardCount) {
		this.playCardCount = playCardCount;
	}

	public int getKeepCardCount() {
		return keepCardCount;
	}

	public void setKeepCardCount(int keepCardCount) {
		this.keepCardCount = keepCardCount;
	}

	public String getPolicyDescription() {
		return policyDescription;
	}

	public void setPolicyDescription(String policyDescription) {
		this.policyDescription = policyDescription;
	}

	public int getCharacterType() {
		return characterType;
	}

	public void setCharacterType(int characterType) {
		this.characterType = characterType;
	}
	
	public static CharacterCard getCharactCardById(String cardId){
		CharacterCard card = null;
		List<Integer> policyList = null;
		if("caocao".equals(cardId)){
			//set cao cao character card.
			card = new CharacterCard("caocao", "Cao Cao");
			card.setCharacterType(CharacterCard.TYPE_KING);
			//set cao cao policy --JianXiong
			policyList = new ArrayList<Integer>();
			policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_CAOCAO_JIANXIOING);
			//set the second policy --HuJia
			card.setPolicyList(policyList);
			card.setPolicyDescription("Get the card that hurt to lost life auto.");
		}else if("liubei".equals(cardId)){
			//set liu bei character card.
			card = new CharacterCard("liubei", "Liu Bei");
			card.setCharacterType(CharacterCard.TYPE_GENERAL);
			policyList = new ArrayList<Integer>();
			policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_LIUBEI_RENDE);
		//		policy = new CaoCaoPolicy("jiJiang", "JiJiang");
		//		policy.setType(CharacterPolicy.TYPE_BE_HURTED);
		//		policy.setIsFixed(true);
		//		policyList.add(policy);
			card.setPolicyList(policyList);
			card.setPolicyDescription("Send cards to one selected user, each send two card can plus one life.");
		}else if("sunquan".equals(cardId)){
			//set sun quan character card.
			card = new CharacterCard("sunquan", "Sun Quan");
			card.setCharacterType(CharacterCard.TYPE_GENERAL);
			policyList = new ArrayList<Integer>();
			policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_SUNQUAN_ZHIHENG);
			card.setPolicyList(policyList);
			card.setPolicyDescription("Select cards to change new cards.");
		}else if("zhangfei".equals(cardId)){
			//set zhang fei character card.
			card = new CharacterCard("zhangfei", "Zhang Fei");
			card.setCharacterType(CharacterCard.TYPE_GENERAL);
			policyList = new ArrayList<Integer>();
			policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_ZHANGFEI_PAOXIAO);
			card.setPolicyList(policyList);
			card.setPolicyDescription("No limit to do attack card.");
		}else if("zhouyu".equals(cardId)){
			//set zhou yu character card.
			card = new CharacterCard("zhouyu", "Zhou Yu");
			card.setCharacterType(CharacterCard.TYPE_GENERAL);
			policyList = new ArrayList<Integer>();
			policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_ZHOUYU_YINZI);
			card.setPolicyList(policyList);
			card.setPolicyDescription("Get three cards on his turn.");
		}else if("guojia".equals(cardId)){
			//set Guo Jia character card.
			card = new CharacterCard("guojia", "Guo Jia");
			card.setCharacterType(CharacterCard.TYPE_GENERAL);
			policyList = new ArrayList<Integer>();
			policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_GUOJIA_YIJI);
			card.setPolicyList(policyList);
			card.setPolicyDescription("Get two cards auto, when be hurt to lost life.");
		}else if("zhaoyun".equals(cardId)){
			//set Zhao Yun character card.
			card = new CharacterCard("zhaoyun", "Zhao Yun");
			card.setCharacterType(CharacterCard.TYPE_GENERAL);
			policyList = new ArrayList<Integer>();
			policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_ZHAOYUN_LONGDAN);
			card.setPolicyList(policyList);
			card.setPolicyDescription("output attack card as defend card, or output defend card as attack card.");
		}else if("huanggai".equals(cardId)){
			//set Huang Gai character card.
			card = new CharacterCard("huanggai", "Huang Gai");
			card.setCharacterType(CharacterCard.TYPE_GENERAL);
			policyList = new ArrayList<Integer>();
			policyList.add(PolicyCenter.POLICY_CHARACTER_CARD_HUANGGAI_KUROU);
			card.setPolicyList(policyList);
			card.setPolicyDescription("Cut one point life initiative to get two cards");
		}else if(cardId == ""){
			
		}else if(cardId == ""){
			
		}else if(cardId == ""){
			
		}else if(cardId == ""){
			
		}
		return card;
	}
	
}
